import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { HydratedDocument } from 'mongoose'

export type SubjectDocument = HydratedDocument<Subject>

@Schema()
export class Subject {
  @Prop({ required: true, type: String })
  title: string

  @Prop({ default: 0, type: Number })
  subjectType: number

  @Prop({ default: '' })
  subjectImage: string

  @Prop({
    default: [],
    type: [
      {
        optionText: { type: String },
        optionType: { type: Number },
        optionImage: { type: String },
        isCorrect: { type: Boolean }
      }
    ]
  })
  options: {
    optionText: string
    optionType: number
    optionImage: string
    isCorrect: boolean
  }[]

  @Prop({ default: '', type: String })
  analysisText: string

  @Prop({ default: '', type: String })
  analysisVideo: string
}

export const SubjectSchema = SchemaFactory.createForClass(Subject)
